home *** CD-ROM | disk | FTP | other *** search
- /*
- * Z_Buffer.h - class definition for zBuffer renderer.
- *
- * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
- * University of Berne, Switzerland
- * All rights reserved.
- *
- * This software may be freely copied, modified, and redistributed
- * provided that this copyright notice is preserved on all copies.
- *
- * You may not distribute this software, in whole or in part, as part of
- * any commercial product without the express consent of the authors.
- *
- * There is no warranty or other guarantee of fitness of this software
- * for any purpose. It is provided solely "as is".
- *
- */
-
- #ifndef Z_Buffer_H
- # define Z_Buffer_H
-
- #include <stdio.h>
- #include "Vector.h"
- #include "ViewTransform.h"
- #include "Color.h"
- #include "Polygon.h"
-
- //___________________________________________________________ Z_Buffer
- class EdgeList;
-
- class Z_Buffer
- {
- public:
- Z_Buffer(ViewTransform* v, const rcString& msg, const rcString& oname);
- ~Z_Buffer();
-
- void renderTriangle(const Color&, const Vector&, const Vector&, const Vector&);
- void renderRectangle(const Color&,
- const Vector&, const Vector&, const Vector&, const Vector&);
- void renderPolygon(const Color&, Polygon*);
-
- void writePixmap();
- long primitives() const;
-
- private:
- void addEdge(const Vector&, const Vector&);
- void render();
- void calculateColor(const Color&, const Vector&, const Vector&);
-
- private:
- rcString remark; // remark for the ppm-File
- ViewTransform* view; // view transformation to apply
- int resX, resY; // screen resolution
- FILE* outfile;
-
- EdgeList** yBuckets;
- float* zBuffer;
- unsigned char* pixmap;
- float R, G, B; // current color
- int ymin, ymax; // height of current polygon
- long numPrimitives; // number of primitives already drawn
- };
-
- inline long Z_Buffer::primitives() const {
- return numPrimitives;
- }
-
- #endif // Z_Buffer_H
-